<include file="Common:layout" />
<body style="background-color: rgb(255, 255, 255); overflow: auto; cursor: default; -moz-user-select: inherit;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>商品管理</h3>
            </div>
        </div>
    </div>

    <div class="flexigrid">
        <div class="mDiv" style="float: left;margin-bottom: 10px;">
            <form action="" class="navbar-form form-inline" method="post" onsubmit="return false;">
                <div class="sDiv">
                    <div class="sDiv2">

                        <select name="shop_id" id="shop_id" class="select" style="min-width:130px;">
                            <option value="">所有店铺</option>
                            <volist name="shops" id="shop">
                                <option value="{$shop['id']}">{$shop['shop_name']}</option>
                            </volist>
                        </select>


                        <select name="cate_id" id="cat_id" class="select" style="min-width:130px;">
                            <option value="">所有分类</option>
                            <volist name="categories" id="category">
                                <option value="{$category['id']}" <if condition="$category['id'] eq $params['cate_id']">selected</if>>
                                <for start="1" end="$category['level']">--</for>{$category['c_name']}
                                </option>
                            </volist>
                        </select>
                        <select name="brand_id" id="brand_id" class="select">
                            <option value="">所有品牌</option>
                            <volist name="brands" id="brand">
                                <option value="{$brand['id']}" <if condition="$brand['id'] eq $params['brand_id']">selected</if>>{$brand['b_name']}</option>
                            </volist>
                        </select>
                        <select name="end_shelves" id="end_shelves" class="select">
                            <option value="">上下架</option>
                            <option value="1" <if condition="$params['end_shelves'] eq 1">selected</if>>上架</option>
                            <option value="-1" <if condition="$params['end_shelves'] eq -1">selected</if>>下架</option>
                        </select>

                        <!--
                        <select name="intro" class="select" id="intro">
                            <option value="">热卖或推荐</option>
                            <option value="is_hot" <if condition="$params['intro'] eq 'is_hot'">selected</if>>热卖</option>
                            <option value="is_recommend" <if condition="$params['intro'] eq 'is_recommend'">selected</if>>推荐</option>
                        </select>
                        -->

                        <!--排序规则-->
                        <input type="text" size="30" name="g_name" id="g_name" placeholder="商品名称">
                        <input type="hidden" id="orderby1" value="id"/>
                        <input type="hidden" id="orderby2" value="DESC"/>
                        <input type="button" class="btn" value="搜索" onclick="ajax_get_table(1);"/>
                    </div>
                </div>
            </form>
        </div>

        <div class="hDiv">
            <div class="hDivBox">
                <table cellspacing="0" cellpadding="0">
                    <thead>
                    <tr>
                        <th align="left" abbr="article_title" axis="col6" class="mhover">
                            <div style="text-align: left; width:30px;" class="" onclick="sort('id')">ID</div>
                        </th>
                        <th align="center" abbr="ac_id" axis="col4">
                            <div style="text-align: center; width: 50px;" class="">主图</div>
                        </th>
                        <th align="left" abbr="ac_id" axis="col4">
                            <div style="text-align: left; width: 200px;">商品名称</div>
                        </th>
                        <th align="center" abbr="article_show" axis="col6">
                            <div style="text-align: center; width: 80px;">货号</div>
                        </th>
                        <th align="center" abbr="article_time" axis="col6">
                            <div style="text-align: center; width: 80px;">品牌</div>
                        </th>
                        <th align="center" abbr="article_time" axis="col6">
                            <div style="text-align: center; width: 100px;">分类</div>
                        </th>
                        <th align="center" abbr="article_time" axis="col6">
                            <div style="text-align: center; width: 100px;">店铺名称</div>
                        </th>
                        <th align="center" abbr="article_time" axis="col6" class="mhover">
                            <div style="text-align: center; width: 50px;" onclick="sort('price')">价格</div>
                        </th>
                        <th align="center" abbr="article_time" axis="col6" class="mhover">
                            <div style="text-align: center; width: 50px;" onclick="sort('end_shelves')">状态</div>
                        </th>
                        <th align="center" abbr="article_time" axis="col6" class="">
                            <div style="text-align: center; width: 80px;">库存（件/箱）</div>
                        </th>
                        <th align="center" abbr="article_time" axis="col6" class="">
                            <div style="text-align: center; width: 160px;">操作</div>
                        </th>
                        <th style="width:100%" axis="col7">
                            <div></div>
                        </th>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>

        <div id="ajax_return"></div>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function(){
        // ajax 加载商品列表
        ajax_get_table(1);

        // 刷选条件 鼠标 移动进去 移出 样式
        $(".hDivBox > table > thead > tr > th.mhover").mousemove(function(){
            $(this).addClass('thOver');
        }).mouseout(function(){
            $(this).removeClass('thOver');
        });
    });


    // ajax 抓取页面 form 为表单id  page 为当前第几页
    function ajax_get_table(page){
        cur_page = page; //当前页面 保存为全局变量
        $.ajax({
            type : "POST",
            url:"{:U('Good/ajax_goods_list')}",
            data : {
                p :page,
                cat_id :$("#cat_id").val(),
                shop_id: $("#shop_id").val(),
                brand_id :$("#brand_id").val(),
                end_shelves :$("#end_shelves").val(),
                intro :$("#intro").val(),
                g_name :$("#g_name").val(),
                orderby1 :$("#orderby1").val(),
                orderby2 :$("#orderby2").val()
            },
            success: function(data){
                $("#ajax_return").html('');
                $("#ajax_return").append(data);
            }
        });
    }

    // 点击排序
    function sort(field)
    {
        $("#orderby1").val(field);
        var v = $("#orderby2").val() == 'desc' ? 'asc' : 'desc';
        $("#orderby2").val(v);
        ajax_get_table(cur_page);
    }
</script>
</body>
</html>